import myAxios from "../utils/axios";
/**
 * 获取所有文章
 * @returns 文章列表
 */
export function GetAllArticle() {
    return myAxios({
        url: "/articles",
        method: "get",
    });
}

/**
 * 获取文章详情
 * @param {string} id 文章id
 * @returns 文章详情
*/
export function GetArticleById(id) {
    return myAxios({
        url: `/articles/${id}`,
        method: "get",
    });
}
/**
 * 创建文章
 * @param {Object} data 文章数据
 * @returns 
 */
export function CreateArticle(data) {
    let article = {
        article: data
    }
    console.log('装载内容')
    console.log(article)
    return myAxios({
        url: "/articles",
        method: "post",
        data: article,
    });
}

export function Subfavorite(id) {
    return myAxios({
        url: `/articles/${id}/favorite`,
        method: "post",
    });
}

export function Unsubfavorite(id) {
    return myAxios({
        url: `/articles/${id}/favorite`,
        method: "delete",
    });
}